/*
2021-7-28
https://www.acwing.com/problem/content/3786/
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>q;
    
    for(ll i=1;i<=n/i;i++)
        if(n%i==0)
        {
            q.push_back(i);
            if(i!=n/i) q.push_back(n/i);
        }
    
    if(k>q.size()) puts("-1");
    else
    {
        sort(q.begin(),q.end());
        cout<<q[k-1]<<endl;
    }
    
    return 0;
}
